package com.jnks.controller;

import com.jnks.constant.R;
import com.jnks.pojo.domain.vo.DroneCoorResponse;
import com.jnks.pojo.domain.vo.DroneDataReq;
import com.jnks.service.impl.DroneDataServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * 在飞无人机
 */
@RestController
@RequestMapping("/vehicle/drone")
@RequiredArgsConstructor
public class DroneDataController {

    private final DroneDataServiceImpl droneDataService;


    /**
     * 获取在飞无人机列表
     * @return
     */
    @GetMapping("/hisDroneDirectDaily")
    public R hisDroneDirectDaily() {
        return R.data(droneDataService.hisDroneDirectDaily());
    }

    /**
     * 获取当前无人机前端未接收轨迹
     * @param droneKey
     * @return
     */
    @GetMapping("/hisDroneCoors")
    public R hisDroneCoors(String droneKey) {
        return R.data(droneDataService.hisDroneCoors(droneKey));
    }

    /**
     * 历史回放-无人机历史轨迹
     * @param req
     * @return
     * @throws ParseException
     */
    @PostMapping("/detail")
    //@PreAuthorize("hasAuthority('drone:detail')")
    public DroneCoorResponse getDroneData(@ModelAttribute DroneDataReq req) throws ParseException {
        return droneDataService.getDroneData(req);
    }

}
